using System;
using NUnit.Framework;
using DotNetXmlSwfChart;

namespace DotNetXmlSwfChart.UnitTest
{
    [TestFixture]
    public class LegendTransitionFixture
    {
        [Test]
        public void DissolveTransition()
        {
            LegendTransitionTest(TransitionType.dissolve);
        }

        [Test]
        public void BlinkTransition()
        {
            LegendTransitionTest(TransitionType.blink);
        }

        [Test]
        public void DropTransition()
        {
            LegendTransitionTest(TransitionType.drop);
        }

        [Test]
        public void NoTransition()
        {
            LegendTransitionTest(TransitionType.none);
        }

        [Test]
        public void ScaleTransition()
        {
            LegendTransitionTest(TransitionType.scale);
        }

        [Test]
        public void SlideDownTransition()
        {
            LegendTransitionTest(TransitionType.slide_down);
        }

        [Test]
        public void SlideLeftTransition()
        {
            LegendTransitionTest(TransitionType.slide_left);
        }

        [Test]
        public void SlideRightTransition()
        {
            LegendTransitionTest(TransitionType.slide_right);
        }

        [Test]
        public void SlideUpTransition()
        {
            LegendTransitionTest(TransitionType.slide_up);
        }

        [Test]
        public void SpinTransition()
        {
            LegendTransitionTest(TransitionType.spin);
        }

        [Test]
        public void ZoomTransition()
        {
            LegendTransitionTest(TransitionType.zoom);
        }

        private void LegendTransitionTest(TransitionType type)
        {
            string testXml =
                "<legend_transition type='{0}' " +
                                   "delay='2' " +
                                   "duration='3' " +
                                   "/>";
            LegendTransition lt = new LegendTransition();
            lt.Type = type;
            lt.Delay = 2;
            lt.Duration = 3;
            Assert.AreEqual(
                string.Format(testXml, type.ToString()),
                lt.ToSourceXML());
        }
    }
}
